var t = require("../../../@babel/runtime/helpers/typeof"), e = require("../../../utils/themeSkin/skinBehavior"), o = getApp();

Page({
    behaviors: [ e ],
    data: {
        name_of_withdrawal: "",
        store_state: 0,
        show: !1,
        turnover_time: [ "今日", "昨日", "全部" ],
        turnover_time_index: 2,
        language: "",
        store: {
            name: "",
            thumb: ""
        },
        store_product_set: !1,
        income: {
            money_total: 0,
            sure_withdraw_money: 0
        },
        status: 0,
        storeManageOpen: !0,
        details: {}
    },
    onLoad: function(t) {
        this.checkrouter(), this.getStoreInfo(), this.showCash(), this.customizeIncome(), 
        this.getStoreData();
    },
    getStoreData: function() {
        var t = this;
        o._postNetWork({
            url: o.getNetAddresss("plugin.store-cashier.frontend.store.center.index.get-statistics"),
            data: {
                day_type: 0
            },
            success: function(e) {
                var a = e.data, r = a.result, s = a.msg, n = a.data;
                r ? t.setData({
                    details: n
                }) : o.tips(s);
            }
        });
    },
    store_popup: function() {
        this.setData({
            show: !0,
            store_state: this.data.store.operating_state
        });
    },
    onChange: function(t) {
        this.setData({
            store_state: t.detail
        });
    },
    customizeIncome: function() {
        try {
            var t = wx.getStorageSync("mailLanguage");
            if (t) {
                var e = JSON.parse(t);
                this.setData({
                    name_of_withdrawal: e.income.name_of_withdrawal
                });
            }
        } catch (t) {}
    },
    onClose: function() {
        this.setData({
            show: !1
        });
    },
    turnover_handle: function(t) {
        var e = this, a = t.currentTarget.dataset.index;
        this.setData({
            turnover_time_index: a
        });
        var r = 0;
        0 == a ? r = 1 : 1 == a && (r = 2), o._postNetWork({
            url: o.getNetAddresss("plugin.store-cashier.frontend.store.center.index.get-statistics"),
            data: {
                day_type: r
            },
            success: function(t) {
                var a = t.data, r = a.result, s = a.msg, n = a.data;
                r ? e.setData({
                    details: n
                }) : o.tips(s);
            }
        });
    },
    checkrouter: function() {
        var e = this;
        try {
            var o = function() {
                for (var t = wx.getStorageSync("yz_basic_info"), o = t.popularize_page.mini.vue_route, a = 0; a < o.length; a++) if ("storeManage" == o[a]) return e.setData({
                    storeManageOpen: !1
                }), t.popularize_page.mini.mini_url ? wx.showToast({
                    title: "未开启推广权限",
                    duration: 1e3,
                    icon: "none",
                    success: function() {
                        setTimeout(function() {
                            wx.redirectTo({
                                url: t.popularize_page.mini.mini_url
                            });
                        }, 1e3);
                    }
                }) : wx.showModal({
                    content: "未开启推广权限",
                    showCancel: !1,
                    success: function(t) {
                        t.confirm && wx.navigateBack({
                            delta: 1
                        });
                    }
                }), console.log(t.popularize_page.mini.mini_url + "跳转的路径"), {
                    v: void 0
                };
            }();
            if ("object" === t(o)) return o.v;
        } catch (t) {
            console.log(t);
        }
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    getCash: function() {
        wx.navigateTo({
            url: "/packageD/buy/myOrder_v2/myOrder_v2?tag=store&isCash=1"
        });
    },
    showCash: function() {
        var t = this, e = o.getNetAddresss("plugin.store-cashier.frontend.store.enter.enable");
        o._getNetWork({
            url: e,
            success: function(e) {
                var a = e.data;
                if (1 != a.result) return o.tips(a.msg);
                t.setData({
                    status: a.data.status
                });
            }
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    onShareTimeline: function() {},
    goStoreCode: function() {
        wx.navigateTo({
            url: "/packageC/o2o/qrCode/qrCode?store_id=" + this.data.store.store_id + "&key=store"
        });
    },
    goqrCode: function() {
        wx.navigateTo({
            url: "/packageC/o2o/qrCode/qrCode?store_id=" + this.data.store.store_id
        });
    },
    gostoreOrderlist: function() {
        wx.navigateTo({
            url: "/packageA/member/myOrder_v2/myOrder_v2?status=0&orderType=store"
        });
    },
    gopresentationRecord: function() {
        wx.navigateTo({
            url: "/packageA/member/presentationRecord_v2/presentationRecord_v2?i=" + this.data.store.store_id + "&type=store"
        });
    },
    goCommodityManagement: function() {
        wx.navigateTo({
            url: "/packageA/member/supplier/CommodityManagement/CommodityManagement?store_id=" + this.data.store.store_id + "&store=store"
        });
    },
    goGoodsClassify: function() {
        wx.navigateTo({
            url: "/packageC/o2o/GoodsClassify/GoodsClassify?store_id=" + this.data.store.store_id
        });
    },
    gotocloudStock: function() {
        wx.navigateTo({
            url: "/packageI/store_cloud_inventory/index/index"
        });
    },
    getStoreInfo: function() {
        var t = this, e = o.getNetAddresss("plugin.store-cashier.frontend.store.center.index.index");
        o._getNetWork({
            url: e,
            success: function(e) {
                var o = e.data;
                if (1 == o.result) t.setData({
                    store: o.data.store,
                    income: o.data.income,
                    nearby: o.data.nearby,
                    specify_show: o.data.specify_show,
                    is_open_code: o.data.is_open_code,
                    my_store_order: o.data.my_store_order
                }), 1 == o.data.store_product_set && t.setData({
                    store_product_set: o.data.store_product_set
                }), o.data.show_store_balance_award && t.setData({
                    show_store_balance_award: o.data.show_store_balance_award
                }); else {
                    if (o.data.url && o.data.url.search("/o2o/storeApply") >= 0) return void wx.redirectTo({
                        url: "/packageA/member/storeApply/storeApply"
                    });
                    wx.showToast({
                        icon: "none",
                        title: o.msg,
                        duration: 1500
                    });
                }
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    gowithdrawal: function() {
        wx.navigateTo({
            url: "/packageA/member/withdrawal/withdrawal"
        });
    },
    goDiscountsGoods: function() {
        wx.navigateTo({
            url: "/packageB/member/commodity_coupon/commodity_coupon/commodity_coupon"
        });
    },
    gomyStore: function() {
        "1" == this.data.specify_show ? wx.navigateTo({
            url: "/packageC/o2o/o2oStore/o2oStore?store_id=" + this.data.store.store_id + "&fromHome=1"
        }) : wx.navigateTo({
            url: "/packageC/o2o/HomeSeller/HomeSeller?store_id=" + this.data.store.store_id
        });
    },
    gotoStoreGroup: function(t) {
        var e = t.currentTarget.dataset.key;
        "storeBalance" == e ? wx.navigateTo({
            url: "/packageA/member/presentationRecord_v2/presentationRecord_v2?orderType=" + e
        }) : wx.navigateTo({
            url: "/packageC/o2o/o2oGroupActivitylist/o2oGroupActivitylist?store_id=" + this.data.store.store_id
        });
    },
    gorecommendlist: function() {
        wx.navigateTo({
            url: "/packageD/o2o/recommendind/recommendind?store_id=" + this.data.store.store_id
        });
    },
    goAddGoods: function() {
        wx.navigateTo({
            url: "/packageC/o2o/store_add_goods/store_add_goods?store_id=" + this.data.store.store_id + "&store=store"
        });
    },
    modifyStoreStatus: function() {
        var t = this, e = o.getNetAddresss("plugin.store-cashier.frontend.store.center.index.changeStatus");
        o._postNetWork({
            url: e,
            success: function(e) {
                var o = e.data;
                wx.showToast({
                    title: o.msg,
                    icon: "none",
                    duration: 1e3
                }), 1 == o.result && (t.setData({
                    show: !1
                }), t.getStoreInfo());
            }
        });
    }
});